package database

import "time"

type CommentList struct {
	Id              string          `json:"id"`
	Aname           string       `json:"aname"`                            //别名
	Ctime           time.Time    `json:"ctime" `              //评论时间
	Ccontent        string       `json:"ccontent"`           //评论内容
	Uavatar         string       `json:"uavatar"`            //用户头像
}

func (CommentList)TableName() string{
	return "comment"
}

func CommentListByUid(user_id string,start,offset int)(cList []CommentList,totle int64,err error){
	cList = make([]CommentList,0)
	totle,err = Engine.Where("uid = ?",user_id).Count(new(Comment))
	if err !=nil{
		return
	}
	err = Engine.Where("uid = ?",user_id).Limit(offset,start).Find(&cList)
	return
}

func CommentAdd(comment *Comment)(err error){
	_,err = Engine.Insert(comment)
	return
}
